.hover(@color: @color-brand-primary) {
  border-color: tint(@color, 20%);
}

.hover-error() {
  border-color: @color-border-fail;
}

.active(@color: @color-brand-primary) {
  border-color: tint(@color, 20%);
  outline: 0;
  //box-shadow: 0 0 0 2px fade(@color, 20%);
}

.active-error() {
  border-color: @color-border-fail;
  outline: 0;
  //box-shadow: 0 0 0 2px fade(@color-border-fail, 20%);
}

.disabled() {
  background-color: @color-complementary-8;
  opacity: 1;
  cursor: @cursor-disabled;
  color: @color-complementary-6;

  &:hover {
    .hover(@color-border-normal1);
  }
}

.input-large() {
  font-size: @font-size-large;
  padding: @input-padding-vertical-large @input-padding-horizontal;
  height: @input-height-large;
}

.input-middle() {
  padding: @input-padding-vertical-middle @input-padding-horizontal;
  height: @input-height-middle;
  border-radius: @btn-border-radius;
}

.input-small() {
  padding: @input-padding-vertical-small @input-padding-horizontal;
  height: @input-height-small;
  border-radius: @btn-border-radius;
}

.input() {
  display: inline-block;
  width: 100%;
  height: @input-height-base;
  line-height: @line-height-base;
  padding: @input-padding-vertical-base @input-padding-horizontal;
  font-size: @font-size-base;
  border: 1px solid @color-border-normal1;
  border-radius: @btn-border-radius;
  color: @color-text-level2;
  background-color: @color-bg-card;
  background-image: none;
  position: relative;
  cursor: text;
  .placeholder();
  transition: border @transition-time @ease-in-out, background @transition-time @ease-in-out, box-shadow @transition-time @ease-in-out;

  &:hover {
    .hover();
  }

  &:focus {
    .active();
  }

  &[disabled],
  fieldset[disabled] & {
    .disabled();
  }

  // Reset height for textarea
  textarea& {
    max-width: 100%;
    height: auto;
    min-height: @input-height-base;
    vertical-align: bottom;
    font-size: @font-size-base;
  }

  // Size
  &-large {
    .input-large();
  }

  &-middle {
    .input-middle();
  }

  &-small {
    .input-small();
  }

  &-no-border {
    border-radius: 0;
    border-color: transparent;

    &:hover {
      border-color: transparent;
    }

    &:focus {
      border-color: transparent;
      box-shadow: none;
    }

    &[disabled] {
      background-color: transparent;

      &:hover {
        border-color: transparent;
      }
    }
  }
}

.input-error() {
  border: 1px solid @color-border-fail;

  &:hover {
    .hover-error;
  }

  &:focus {
    .active-error;
  }
}

.input-group(@inputClass) {
  display: table;
  width: 100%;
  border-collapse: separate;
  position: relative;
  font-size: @font-size-base;

  .ivu-form-inline & {
    top: 1px; // fixed when using in form inline,
  }

  &-large {
    font-size: @font-size-large;
  }

  // Undo padding and float of grid classes
  &[class*="col-"] {
    float: none;
    padding-left: 0;
    padding-right: 0;
  }

  >[class*="col-"] {
    padding-right: 8px;
  }

  &-prepend,
  &-append,
  >.@{inputClass} {
    display: table-cell;

    //&:not(:first-child):not(:last-child) {
    //    border-radius: 0;
    //}
  }

  &-with-prepend .@{inputClass},
  &-with-prepend&-small .@{inputClass} {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }

  &-with-append .@{inputClass},
  &-with-append&-small .@{inputClass} {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }

  &-prepend .@{css-prefix}btn,
  &-append .@{css-prefix}btn {
    border-color: transparent;
    background-color: transparent;
    color: inherit;
    margin: -(@input-padding-vertical-base + 2) (-@input-padding-horizontal);
  }

  &-prepend,
  &-append {
    width: 1px; // To make addon/wrap as small as possible
    white-space: nowrap;
    vertical-align: middle;
  }

  .@{inputClass} {
    width: 100%;
    float: left;
    margin-bottom: 0;
    position: relative;
    z-index: 2;
  }

  &-prepend,
  &-append {
    padding: @input-padding-vertical-base @input-padding-horizontal;
    font-size: inherit;
    font-weight: normal;
    line-height: 1;
    color: @color-text-level2;
    text-align: center;
    background-color: @color-bg-card;
    border: 1px solid @color-border-normal1;
    border-radius: @btn-border-radius;

    // Reset Select's style in addon
    .@{css-prefix}select {
      margin: -(@input-padding-vertical-base + 1) (-@input-padding-horizontal); // lesshint spaceAroundOperator: false

      &-selection {
        background-color: inherit;
        margin: -1px;
        border: 1px solid transparent;
      }

      &-visible .@{css-prefix}select-selection {
        box-shadow: none;
      }
    }
  }

  // Reset rounded corners
  >span>.@{inputClass}:first-child,
  >.@{inputClass}:first-child,
  &-prepend {
    border-bottom-right-radius: 0 !important;
    border-top-right-radius: 0 !important;

    // Reset Select's style in addon
    .@{css-prefix}-select .@{css-prefix}-select-selection {
      border-bottom-right-radius: 0;
      border-top-right-radius: 0;
    }
  }

  &-prepend {
    border-right: 0;
  }

  &-append {
    border-left: 0;
  }

  >.@{inputClass}:last-child,
  &-append {
    border-bottom-left-radius: 0 !important;
    border-top-left-radius: 0 !important;

    // Reset Select's style in addon
    .@{css-prefix}-select .@{css-prefix}-select-selection {
      border-bottom-left-radius: 0;
      border-top-left-radius: 0;
    }
  }

  // Sizing options
  &-large .@{inputClass},
  &-large>&-prepend,
  &-large>&-append {
    .input-large();
  }

  &-small .@{inputClass},
  &-small>&-prepend,
  &-small>&-append {
    .input-small();
  }
}

.input-group-error {

  &-prepend,
  &-append {
    background-color: @color-bg-card;
    border: 1px solid @color-border-fail;

    .@{css-prefix}select {
      &-selection {
        background-color: inherit;
        border: 1px solid transparent;
      }
    }
  }

  &-prepend {
    border-right: 0;
  }

  &-append {
    border-left: 0;
  }
}